# Based on http://davespicks.com/writing/programming/procmailcopies.html
# Preliminaries -- set up some special variables
SHELL=/bin/sh
LOGFILE=${HOME}/procmail.log
LOG="--- Logging ${LOGFILE} for ${LOGNAME}, "

# Get sender's bare email address because we'll need it later
FROM_=`formail -c -x"From " \
               | expand | sed -e 's/^[ ]*//g' -e 's/[ ]*$//g' \
               | awk '{ print $1 }'`

# note that the 'c' in the :0 c below means that we're working on a copy
# of the email. The original mail is still delivered normally.
:0
# is it from the magical list?
* ^FROM.*(tests@test-message\.appspotmail\.com)
{
  :0 fwh
  # Adjust headers before forwarding
  | formail -A"X-Loop: $emailAddress" \
      -A"X-From-Origin: ${FROM_}"
  # forward the email to the other address
  :0
  # yes? Send it along
  ! tests@test-message.appspotmail.com
}
# if not, toss it